/**
 * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
 */
// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作
const install = (Vue, vm) => {

	// 参数配置对象
	const config = vm.vuex_config;

	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {

		// 基础服务：登录登出、身份信息、菜单授权、切换系统、字典数据等
		lang: (params = {}) => vm.$u.get('/lang/' + params.lang),
		index: (params = {}) => vm.$u.get(config.adminPath + '/mobile/index', params),
		//获取待办列表
		getDaibanList: (params = {}) => vm.$u.post(config.adminPath + '/app/cms/getDaiban', params),
		//获取待办详情
		getDaibanForm: (params = {}) => vm.$u.get(config.adminPath + '/app/cms/getGwDataForm', params),
		//登录
		login: (params = {}) => vm.$u.post(config.adminPath + '/login', params, {
			'content-type': 'application/x-www-form-urlencoded' // 显式设置 Content-Type
		}),
		// 获取退回列表
		getBackNodes: (params = {}) => vm.$u.get(config.adminPath + '/app/cms/getBackNodes', params),
		// 退回任务
		backTask: (params = {}) => vm.$u.get(config.adminPath + '/app/cms/backTask', params),
		// 获取下一环节数据
		getNextTasks: (params = {}) => vm.$u.get(config.adminPath + '/app/cms/getNextTasks', params),
		// 获取参与人员数据
		getNextUsers: (params = {}) => vm.$u.get(config.adminPath + '/app/cms/getNextUsers', params),
		// 发送操作（发文、传真电报）
		sendFw: (params = {}) => vm.$u.post(config.adminPath + '/app/cms/sendFw', params),
		// 发送操作（呈报件、请示件、收文）
		sendSw: (params = {}) => vm.$u.post(config.adminPath + '/app/cms/sendSw', params),
		// 发送操作（来宾报告）
		sendLbbg: (params = {}) => vm.$u.post(config.adminPath + '/app/cms/sendLbbg', params),
		// 发送操作（外出报告单）
		sendWcbg: (params = {}) => vm.$u.post(config.adminPath + '/app/cms/sendWcbg', params),
		// 获取签收数据
		getQianshou: (params = {}) => vm.$u.post(config.adminPath + '/app/cms/getQianshou', params),

		// 获取重要信息列表（废弃）
		getImportantNews: (params = {}) => vm.$u.get(config.importantBaseUrl + '/cm/cmNtko1/zhzb', {
			type: 1,
			cateCodes: '8ae8c18369f4fe350169f67bdb6f0000',
			pageNo: params.pageNo || 1,
			pageSize: params.pageSize || 5
		}),

		// 获取重要信息详情（废弃）
		getArticleDetail: (id) => vm.$u.get(config.importantBaseUrl + '/cm/cmNtko1/getArticle', {
			articleId: id
		}),
		//获取新闻栏目
		getSiteCategory: (params = {}, headers = {}) => {
			return vm.$u.get(config.adminPath + '/app/cms/getSiteCategory', params);
		},
		// 获取重要信息列表
		getArticleListOld: (params = {}, headers = {}) => {
			return vm.$u.get(config.adminPath + '/app/cms/getArticleList', params);
		},
		// 获取重要信息列表
		getArticleList: (params = {}, headers = {}) => {
			return vm.$u.get(config.importantBaseUrl + '/cm/cmNtko1/zhzb', params);
		},


		// 根据token获取黄委id
		getHwIdByToken: (params = {}) => vm.$u.post('https://hw.sdhwj.com/oauth2/userinfo', params),

		// 获取sessionId
		getSessionIDByHwId: (params = {}) => vm.$u.get('https://xdoc.sdhwj.com/cm/cmNtko1/ssoLogin', params),

		// 增删改查例子
		testData: {
			form: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/form', params),
			list: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/listData', params),
			save: (params = {}) => vm.$u.postJson(config.adminPath + '/test/testData/save', params),
			disable: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/disable', params),
			enable: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/enable', params),
			delete: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/delete', params),
		},

	};

}

export default {
	install
}